<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>登录页面</title>
</head>
<body>
<form class="form-horizontal col-md-offset-4 col-lg-offset-4col-xl-offset-4"
      method="post">
    <div class="form-group">
        <label for="inputusername3" class="col-sm-2 control-label">用户名</label>
        <div class="col-sm-2">
            <input type="text" class="form-control" id="inputusername3" name="username" placeholder="username">
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-2">
            <input type="password" class="form-control" id="inputPassword3" name="password" placeholder="Password">
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" id="loginBtn" class="btn btn-default">登录</button>
        </div>
    </div>
</form>
</body>

<%@include file="common/head.jsp"%>
<%@include file="common/tag.jsp"%>
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
<!-- 导入MD5加密算法插件-->
<script src="/resources/script/jquery.md5.js" type="text/javascript"></script>

<script src="/resources/script/login.js" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $('#loginBtn').one('click',function () {
            var salt="162846^*^(^hdukw";
            var userName=$('#inputusername3').val();
            var password=$('#inputPassword3').val();
            var passwordMd5 = $.md5(password+salt);
            $.post(login.URL.login(userName,passwordMd5),{},function (result) {
                console.log(result['login']);
                if(result){
                    if(result['login']){
                        alert(result['info']);
                        window.location.href=login.URL.list();
                        // $(location).attr('href',login.URL.list());
                    }
                    else {
                        alert(result['info']);
                    }
                }else{
                    alert("系统异常!");
                }
            });
        });
    })
</script>
</html>
